

<!DOCTYPE html>
<html>
<head>
  <meta charset="utf-8">
  <title>高度最大适应 - 数据表格</title>
  <meta name="renderer" content="webkit">
  <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
  <meta name="viewport" content="width=device-width, initial-scale=1.0, minimum-scale=1.0, maximum-scale=1.0, user-scalable=0">
  <link rel="stylesheet" href="../../layuiadmin/layui/css/layui.css" media="all">
  <link rel="stylesheet" href="../../layuiadmin/style/admin.css" media="all">

  <!--jquery-->
  <script src="../../statics/libs/jquery.min.js"></script>
  <!--ztree-->
  <link rel="stylesheet" href="../../statics/plugins/ztree/css/zTreeStyle/zTreeStyle.css">
  <script src="../../statics/plugins/ztree/jquery.ztree.all.min.js"></script>

  <script src="../../js/common.js"></script>

</head>
<body>

<div class="layui-fluid">
  <hr>
  <div class="layui-row">
    <div class="layui-col-md12">
      <div style="overflow-y: auto;max-height: 250px">
        <ul id="dataTree" class="ztree"></ul>
      </div>
    </div>
  </div>
</div>

  
  <script src="../../layuiadmin/layui/layui.js"></script>
  <script>
  layui.config({
    base: '../../layuiadmin/' //静态资源所在路径
  }).extend({
    index: 'lib/index' //主入口模块
  }).use(['index', 'table'], function(){
    var admin = layui.admin
    ,layer = layui.layer
    ,layerTips = parent.layer === undefined ? layui.layer : parent.layer //获取父窗口的layer对象
    ,$ = layui.jquery;



      //部门树------------start
      var data_ztree;
      var data_setting;

      data_setting = parent.data.isMulti?{
          view: {
              selectedMulti: false,
          },
          data: {
              simpleData: {
                  enable: true,
                  idKey: "deptId",
                  pIdKey: "parentId",
                  rootPId: -1
              }
          },
          check: {
              enable: true,
              chkboxType: {"Y": "", "N": ""}
          },
          edit: {
              enable: false,
              showRemoveBtn: false,
              showRenameBtn: false
          }
      }:{
          view: {
              selectedMulti: false,
          },
          data: {
              simpleData: {
                  enable: true,
                  idKey: "deptId",
                  pIdKey: "parentId",
                  rootPId: -1
              }
          },
          check: {
              enable: true,
              chkStyle: "radio",
              radioType: "all"
          },
          edit: {
              enable: false,
              showRemoveBtn: false,
              showRenameBtn: false
          }
      };

      function getDataTree() {
          //加载菜单树
          Ajax.request({
              url: "../common/dept.js",
              async: true,
              successCallback: function (r) {
                  data_ztree = $.fn.zTree.init($("#dataTree"), data_setting, r.list);
                  //展开所有节点
                  data_ztree.expandAll(true);
              }
          });
      };

      getDataTree();
      //部门树------------end
  });


  function getCheckedNodes(){
      var zTree = $.fn.zTree.getZTreeObj("dataTree");
      //var nodes = zTree.transformToArray(zTree.getNodes());
      var nodes = zTree.getCheckedNodes(true);
      return nodes;
  }


  </script>
</body>

<div id="addDialog" style="display: none">
    <div id="tmpDiv">

      <!--<div class="layui-row" style="margin-top: 10px">
        <div class="layui-col-xs4">部门Id</div>
        <div class="layui-col-xs8">
          <input id="add_id" type="text" placeholder="请输入ID" class="layui-input">
        </div>
      </div>-->

      <div class="layui-row" style="margin-top: 10px">
        <div class="layui-col-xs4">部门名称</div>
        <div class="layui-col-xs8">
          <input id="add_name" type="text" placeholder="请输入名称" class="layui-input">
        </div>
      </div>
      <div class="layui-row" style="margin-top: 10px">
        <div class="layui-col-xs4">上级部门</div>
        <div class="layui-col-xs8">
          <input type="text" id="add_pName" placeholder="请选择上级部门" readonly class="layui-input">
          <input type="hidden" id="add_pId">
          <input type="hidden" id="add_pTid">
        </div>
      </div>

          <div id="menuContent" class="menuContent" style="display:none; position: absolute;">
            <ul id="treeSelect" class="ztree" style="margin-top:0; width:160px;"></ul>
          </div>
    </div>

</div>

</html>